﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GWModflow.FileLayers
{
    public class PSpecifiedHead : Package
    {

       public PSpecifiedHead()
        {

            this._fileType=FileType.CHD;
            this.Fname = "solution.chd";


            this.Nunit = 45;


            this._periodsData = new List<SPSpecifiedHead>();

        }


        int _MAXACTC;

        public int MAXACTC
        {
            get { return _MAXACTC; }
            set { _MAXACTC = value; }
        }


        List<SPSpecifiedHead> _periodsData;

        public List<SPSpecifiedHead> PeriodsData
        {
            get { return _periodsData; }
            
        }



        public override void WriteFile(string path)
        {
            string content = "# HuanAnKeJi CHD File" + "\r\n";
            content += string.Format("{0,6}", this.MAXACTC) + "\r\n";
            string str = "";
            foreach (SPSpecifiedHead sp in this.PeriodsData)
            {
                str += sp.ITMP + "    " + sp.NP + "\r\n";
                if (sp.ITMP >= 0)
                {
                    for (int i = 0; i < sp.HeadsData.Count; i++)
                    {
                        str += string.Format("{0,10}", sp.HeadsData[i].Layer) + " " + string.Format("{0,10}", sp.HeadsData[i].Row) + " " +
                              string.Format("{0,10}", sp.HeadsData[i].Column) + " " + string.Format("{0,10}", sp.HeadsData[i].Value) + " " +
                              string.Format("{0,10}", sp.HeadsData[i].Value2) + "\r\n";// +string.Format("{0,10}", sp.HeadsData[i].Value3) + "\r\n";
                    }
                }
            }
            content += str;

            string fname = path + this.Fname;
            FXnaInfrastructure.FileHelper.WriteFile(fname, content);
        }

    }
}
